#include <iostream>
#include <vector>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <string>
#include <unordered_map>
#include <functional>
#define PROCESS_NUM 5 // 创建进程个数
using namespace std;

int main()
{
    vector<int> _STL;
    for (int i = 0; i < PROCESS_NUM; i++)
    {
        int pipefd[2] = {0};
        int n = pipe(pipefd); // pipe返回值，管道创建成功返回0，失败返回-1
        pid_t id = fork();

        if (id == 0)
        {
            close(pipefd[1]);
            int a;
            cin >> a;
            exit(1);
        }
        close(pipefd[0]);
        _STL.push_back(pipefd[1]);
    }
    for (int i = 0; i < _STL.size(); i++)
    {
        cout << "该次进程的写端为：" << _STL[i] << endl;
    }
    return 0;
}